import mysql.connector
import xlsxwriter

def load_data(sql,filename):
    conn = mysql.connector.connect(host = '120.79.184.105',user='root', password='root', database='test', use_unicode=True)
    cursor = conn.cursor()
    cursor.execute(sql)
    workbook = xlsxwriter.Workbook(filename)
    worksheet = workbook.add_worksheet()
    i=0
    for line in cursor:
        j=0
        for row in line:
            worksheet.write(i, j, row)
            j+=1
        i+=1
    workbook.close()

sql='select'
filename='data.xlsx'

load_data(sql,filename)